import { defineStore } from "pinia";
import { ref } from "vue";

const userLoginStore = defineStore(
    'userLoginStore',
    () => {

        const loginInfo = ref({
            username    : '',
            password    : ''
        });

        //2.定义修改userInfo的方法
        const setLoginInfo = (user_name,pass_word) => {
            loginInfo.value.username = user_name;
            loginInfo.value.password = pass_word;
        }

        //3.定义移除userInfo的方法
        const removeLoginInfo = () => {
            loginInfo.value.username = '';
            loginInfo.value.password = '';
        }
        return {
            loginInfo,setLoginInfo,removeLoginInfo
        }
    },
    {
        persist:true
    }
)

export default userLoginStore;